package se.sll.itintegration.catalogue.product.entity;

import java.io.Serializable;
import java.util.Set;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import lombok.AccessLevel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

/**
 *
 * @author khaleddaham
 * @author Jiri Uosukainen
 */
@SuppressWarnings("PMD.UnusedPrivateField")
@Entity
@Data
@Table(name = "codesystem")
@EqualsAndHashCode(of = {"oid"})
@ToString(exclude = {"codes"})
public class CodeSystemEntity implements Serializable {

    @Id
    @GeneratedValue
    @Getter(AccessLevel.NONE)
    @Setter(AccessLevel.NONE)
    private Long id;
    
    @Column(unique = true, updatable = false)
    private String oid;

    @NotNull
    private String name;
    
    @NotNull
    private String description;
    
    @Fetch(FetchMode.SUBSELECT)
    @OneToMany(mappedBy="codeSystem",  fetch = FetchType.EAGER)
    private Set<CodeEntity> codes;
}